package edu.wfu.preparedDishes.commodity.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import edu.wfu.preparedDishes.commodity.dao.CommoditySpuDao;
import edu.wfu.preparedDishes.commodity.entity.CommoditySpuEntity;
import edu.wfu.preparedDishes.commodity.entity.commodityVo;
import edu.wfu.preparedDishes.commodity.service.CommoditySpuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("commoditySpuService")
public class CommoditySpuServiceImpl extends ServiceImpl<CommoditySpuDao, CommoditySpuEntity> implements CommoditySpuService {

    @Autowired
    private CommoditySpuDao dao;




    @Override
    public List<commodityVo> queryCommodities(int pageSize, int offset, String orderBy,String merchantId,String spuNameLike,String classification,String spuId) {
        return dao.queryListWithPagination(pageSize, offset, orderBy, merchantId,spuNameLike,classification,spuId);
    }

    @Override
    public CommoditySpuEntity getCommodityBySpuId(String spuId) {
        QueryWrapper<CommoditySpuEntity> wrapper = new QueryWrapper<CommoditySpuEntity>()
                .eq("spu_id",spuId);
        return this.getOne(wrapper);
    }
}